/*
 *    Copyright (c) 2018-2025, infomng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: infomng
 */

import request from "@/router/axios";

export function fetchList(query) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/page",
    method: "get",
    params: query,
  });
}

export function addObj(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling",
    method: "post",
    data: obj,
  });
}

export function getObj(id) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/" + id,
    method: "get",
  });
}

export function delObj(id) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/" + id,
    method: "delete",
  });
}

export function putObj(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling",
    method: "put",
    data: obj,
  });
}

/**
 * 产线排产添加工单
 * @param obj
 * @returns {AxiosPromise}
 */
export function saveDocNo(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/saveDocNo",
    method: "post",
    data: obj,
  });
}

/**
 * 根据排产ID获取工单号字符串集合
 */
export function getDocNoStr(scheduleId) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/getDocNoStr/" + scheduleId,
    method: "get",
  });
}

/**
 * 工单管理新排产保存排产页面添加的信息
 */
export function saveWorkSchedulingInfo(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/saveWorkSchedulingInfo",
    method: "post",
    data: obj,
  });
}

/**
 * 根据工单号查询排产信息
 * @param docNo
 * @returns {AxiosPromise}
 */
export function getWorkSchedulingInfo(docNo) {
  return request({
    url:
      "/admin-api/o3-workorder/workscheduling/getWorkSchedulingInfo/" + docNo,
    method: "get",
  });
}
export function updateSchedule(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling",
    method: "put",
    data: obj,
  });
}
export function delSchedule(id) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/" + id,
    method: "delete",
  });
}

/**
 * 获取产线下排产工单信息
 * @returns {AxiosPromise}
 * @param obj
 */
export function getWorkScheduleListByLineId(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/getWorkScheduleListByLineId/",
    params: obj,
    method: "get",
  });
}
/**
 * 排产工单排序
 * @param obj
 * @returns {AxiosPromise}
 */
export function workScheduleOrderSort(obj) {
  return request({
    url: "/admin-api/o3-workorder/workscheduling/workScheduleOrderSort",
    method: "post",
    data: obj,
  });
}
